﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace NCS.IConnect.Core.WebApi.Description
{
    /// <summary>
    /// 
    /// </summary>
    public class SampleDataKey
    {
        /// <summary>
        /// 
        /// </summary>
        public Type SampleType { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public HttpMethod HttpMethod { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string ControllerName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string ActionName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            int hashCode = 0;
            if (null != SampleType)
            {
                hashCode ^= this.SampleType.GetHashCode();
            }
            if (null != this.HttpMethod)
            {
                hashCode ^= this.HttpMethod.GetHashCode();
            }
            if (null != ControllerName)
            {
                hashCode ^= this.ControllerName.ToLower().GetHashCode();
            }
            if (null != ActionName)
            {
                hashCode ^= this.ActionName.ToLower().GetHashCode();
            }
            return hashCode;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            SampleDataKey key = obj as SampleDataKey;
            if (null == key)
            {
                return false;
            }

            return key.SampleType == this.SampleType &&
                this.HttpMethod == key.HttpMethod &&
                (key.ControllerName??"").ToLower() == (this.ControllerName??"").ToLower() &&
                (key.ActionName??"").ToLower() == (this.ActionName??"").ToLower();
        }

    }
}
